Latitude and longitude average by CEP

Asked

Viewed 1,360 times

4

I need to find the starting point and end of CEP latitude/longitude. I need to analyze on average a latitude and longitude and this initial and final parameter would show whether this coordinate is part of the CEP or not. Lately I’m having problems with geolocation API’s and I’m planning to set up a Mysql database with all the zip codes of the streets of my city and averages of latitudes/longitudes to compare with the latitude and longitude I will search in the bank.

I have to get these averages to avoid more than 1 million queries via API per day!

So I want to create this field of average that could be the sum of latitude and longitude or the product to already quickly check in which CEP band that coordinate is. I know that in different localities this gross average may have repetitions but as my focus is on only one city I believe it will not occur.

Is there any way to achieve the initial and final co-ordination of a CEP?

Example:

latitude  = -15.8008398
longitude = -47.86135561

produto = latitude * longitude = (756.2496126044413)

banco = {
     coord_inicial: 750.390348041, (??? Número que preciso encontrar)
     coord_final  : 760.230192319, (??? Número que preciso encontrar)
     cep          : 70100000,
     logradouro   : 'Praça dos três poderes',
     cidade       : 'Brasília'
}

If the product is between initial cohort and the final cohort this location belongs to the CEP.

  • 1

    Man, this problem of yours seems to be a lot more serious than it looks to solve with average coordinates. I say this because: 1) Hardly a street is straight, so the average would not be exactly useful. 2) A map works on a Cartesian plane, so it would be more useful to keep a formula for a line, then calculate the distance of a point on that line and see if this distance is within an acceptable limit. But I still don’t think it would solve your problem.

  • 2
    1. Not always a zip code refers to a single street, there are cities that only have one zip code. Of course, this is not the case for your city, but it may still be the case that a zip code represents more than one street. That said I will follow the proposed solutions because your problem is interesting. + 1
  • @fernandosavio I’m really looking for some way to store repeated data in the database to avoid so many requests in geolocation Apis. It’s an initial idea of my average, I already knew that it would be much more complex to solve with a simple average, but as you said, would I get a sort of limit calculating the distance between these points in the Cartesian plan? Thanks for the tip, I will now study this alternative.

  • I was thinking now... maybe an alternative is to do the opposite, register lat and long zones with their radius or quadrant and register the strains that are within that area

  • @Leandroangelo This is exactly what I was thinking at the weekend, I already downloaded the data from Brazil in osm.pbf format to be generating my own map in closed environment, I will see if it is possible through this API: openstreetmap

1 answer

2

Open Street Map has a feature that may be similar to what you search for, but from the address, which can be discovered using an API or a zip code database, both available, for example, at: http://cep.la/.

I have no knowledge of javascript, but in R, can be accessed with the function geocode_OSM() package tmaptools.

One of the returned elements is Bbox, i.e. bounding box Matrix, that may be useful.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.