[Geocoding] local US nominatim reverse geocode does not return a state unless lat/lon is close to the state centroid

Sarah Hoffmann lonvia at denofr.de
Fri Jan 9 18:48:25 UTC 2015


Hi John,

On Fri, Jan 09, 2015 at 12:02:18PM -0500, John Shimer wrote:
> Hi,
> 
> I have a local Nominatim instance with a US/Pennsylvania extract
> loaded. When a make reverse geocode requests, I never get a state
> back unless the coordinates are close to the centroid of the state.

It's most likely that the extract was cut a bit tight and didn't include
the full state boundary. You can add it to your database after the import
like this:

* Find the relation of Pennsylvania on the osm website and note the ID
  (it's that http://www.openstreetmap.org/relation/162109)
* Import the relation to your database like that:
  ./utils/update.php --import-relation 162109 --index
* Verify that you can find the state now and it will give you back the
  relation. Sometimes OSM data gets broken and then this part will fail.
* When all is well, you have to reindex everything.
  Mark for indexing:
	  psql -d nominatim -c "select place_force_update(place_id) from placex where osm_type = 'R' and osm_id = 162109"
  And reindex:
	  ./utils/update.php --index --index-instances 2

The last part is really slow, I' m afraid. You can also simply reimport
the database with an extract that is a bit larger than the state you need.

Sarah

> 
> I am aware that the openstreetmap version of Nominatim always
> returns valid results for my test coordinates, so what am I doing
> wrong?
> 
> for example... http://myserver/nominatim/reverse.php?format=xml&lat=40.658773&lon=-75.295520
> 
> returns
> 
> <reversegeocodetimestamp="Fri, 09 Jan 15 11:40:46
> -0500"attribution="Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright"querystring="format=xml&lat=40.658773&lon=-75.295520">
> <resultplace_id="637091"osm_type="way"osm_id="19996066"ref="Baglyos
> Circle"lat="40.6608768"lon="-75.2980609">
> Baglyos Circle, Farmersville, Northampton, 18020, United States of America
> </result>
> <addressparts>
> <road>Baglyos Circle</road>
> <hamlet>Farmersville</hamlet>
> <county>Northampton</county>
> <postcode>18020</postcode>
> <country>United States of America</country>
> <country_code>us</country_code>
> </addressparts>
> </reversegeocode>
> 
> while
> 
> http://myserver/nominatim/reverse.php?format=xml&lat=40.736505&lon=-77.884580
> 
> returns
> 
> <reversegeocodetimestamp="Fri, 09 Jan 15 11:45:27
> -0500"attribution="Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright"querystring="format=xml&lat=40.736505&lon=-77.884580">
> <resultplace_id="320232"osm_type="way"osm_id="11842937"ref="Ward
> Alley"lat="40.735668"lon="-77.8842848">
> Ward Alley, Pine Grove Mills, Centre, Pennsylvania, 16801, United
> States of America
> </result>
> <addressparts>
> <road>Ward Alley</road>
> <hamlet>Pine Grove Mills</hamlet>
> <county>Centre</county>
> <state>Pennsylvania</state>
> <postcode>16801</postcode>
> <country>United States of America</country>
> <country_code>us</country_code>
> </addressparts>
> </reversegeocode>
> 
> Thanks,
> John

> _______________________________________________
> Geocoding mailing list
> Geocoding at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/geocoding




More information about the Geocoding mailing list