Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have this query:

http://api.geonames.org/search?featureCode=PPL&username=genadinik&country=US&style=full&adminCode1=AL&maxRows=100

Which brings back the top most populated cities in order by population. The biggest cities in Alabama are Birmingham and Montgomery. But they do not appear on this list, no matter how far down the list I extend the query.

Is there a reason that this happens? Or some rule/design feature that I am not aware of that is causing this?

Thanks!

share|improve this question
    
Montgomery - api.geonames.org/… –  Mapperz Jun 23 '11 at 14:18
    
Birmingham - api.geonames.org/… –  Mapperz Jun 23 '11 at 14:21
1  
Maybe wait for an answer from the GeoNames forum before posting here or vice versa. –  Sean Jun 23 '11 at 17:06
add comment

1 Answer

up vote 3 down vote accepted

The feature code for Montgomery is PPLA, not PPL. Birmingham is PPLA2. You can add them by specifying featureCode more than once, with each feature code you're looking for. Keep in mind that your search is being truncated to the first 100 results.

It's not ordering them by population; the top result after Montgomery and Birmingham is Bessemer, AL (pop 27,456); the next result is Hoover, AL (pop 81,619). You're limiting your search to the first 100 out of 5386 rows (specified in the totalResultsCount tag in the header).Birmingham and Montgomery are probably in the results that are not being returned. The search function doesn't seem to have an ORDER BY equivalent. By the way, the default value for maxRows seems to be 100, so just removing it won't give you the results you're looking for. Setting it to 5386 tells you maxRows is too large. You may need to use a combination of maxRows and startRow to page your results and get a full set.

Another option would be to replace featureCode=PPL with featureCode=PPLA&featureCode=PPLA . This returns just 66 results, but drops cities that aren't county seats. Depends on what you're trying to do.

Good luck! By the way, the documentation I used for the search function is at http://www.geonames.org/export/geonames-search.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.