Mapping in Python
<p>I have at my dispositions a JSON list with all the bike stations called Velib in Paris with their latitude, longitude, number of bikes and capacity. </p>

<p>I am trying to calculate proportion <code>averages(number_of_bikes/bike_capacity)</code> of the number of bikes for the bike stations in different districts of Paris. I would like to create a mapping/function of a city that differentiates different districts(= so that when i put coordinates it sends me back the number or the district )  so that when i try to calculate an average per part of the city i can insert coordinates of the bike stations and it goes directly into the average of the number of bikes of the district it is in. </p>

<p>I can do it when the districts are parallel one to each other delimited by horizontal/ vertical strait lines. </p>

<pre><code>for k in range(len(bike_station_list):
   if lat(bike_station_k)&lt;lat_district_1 and   lng(bike_station_k &lt;lng_disctrict_1

... and so on
</code></pre>

<p>However in reality Paris districts are far more complex.</p>

<p>How can I create a mapping of the city that can tell me in which district I am.</p>

<p>My first idea was to create a huge matrix with all longitudinal and latitudinal coordinates with the number of the district it is in but it looks a bit exaggerated. </p>

<p>Thanks for helping !</p>

<p>You'll need an approximate contour map of your districts, so the boundaries of the districts as a number of e.g. straight line segments. And then you need a way to find out if you're inside such a closed contour.</p>

<p>You'll find how to do that <a href="https://www.quora.com/How-do-I-know-a-point-is-inside-a-closed-curve-or-not" rel="nofollow">here</a></p>

<p>Given the complexity of this algorithm, your large matrix isn't too bad an idea, if you're satisfied with a resolution of say 10 * 10 m. If you want to cover an area of say 30 * 30 km that would be 3000 * 3000 == 9,000,000 squares. Nothing a PC can't easily handle, including the searches involved.</p>

python mapping geocoding reverse-geocoding