1

I am trying to run this Ogr2Ogr command but it doesn't execute when entered. What is wrong?

ogr2ogr -f GeoJson -where "neighborhood IN ('Lower East Side', 'Greenwich Village', 'Columbia St', 'Financial District', 'Flatiron District', 'Williamsburg', 'West Village', 'Central Park', 'Upper West Side', 'Navy Yard', 'Gramercy', 'Stuyvesant Town', 'Upper East Side', 'Clinton Hill', 'SoHo', 'Bedford-Stuyvesant', 'NoHo', 'Vinegar Hill', 'Theater District', 'Park Slope', 'Tribeca', 'Chinatown', 'Midtown', 'Downtown Brooklyn', 'Boerum Hill', 'Kips Bay', "Hells Kitchen", 'Chelsea', 'Two Bridges', 'Civic Center', 'Murray Hill', 'Brooklyn Heights', 'Battery Park City', 'Fort Greene', 'East Village', 'DUMBO', 'Nolita')" output.json nyc-pediacities-neighborhoods-v3-polygon.geojson

My geoJson file looks like the following:

{
"type": "FeatureCollection",

"features": [
{ "type": "Feature", "properties": { "neighborhood": "Allerton", "boroughCode": "2", "borough": "Bronx", "@id": "http:\/\/nyc.pediacities.com\/Resource\/Neighborhood\/Allerton" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.848597000000183, 40.871670000000115 ], [ -73.845822536836778, 40.870239076236174 ], [ -73.854559184633743, 40.859953835764252 ], [ -73.854665433068263, 40.859585694988056 ], [ -73.856388703358959, 40.857593635304482 ], [ -73.868881809153407, 40.857223150158326 ], [ -73.868317552728243, 40.857862062258313 ], [ -73.869553714672321, 40.857784095600181 ], [ -73.871024857620654, 40.857309948816905 ], [ -73.870480549987164, 40.865413584098484 ], [ -73.87055489856489, 40.869702798589863 ], [ -73.86721594442561, 40.869689663636713 ], [ -73.85745, 40.869533000000182 ], [ -73.855550000000108, 40.871813000000145 ], [ -73.853597967576576, 40.873288368674203 ], [ -73.848597000000183, 40.871670000000115 ] ] ] } }
,
{ "type": "Feature", "properties": { "neighborhood": "Alley Pond Park", "boroughCode": "4", "borough": "Queens", "@id": "http:\/\/nyc.pediacities.com\/Resource\/Neighborhood\/Alley_Pond_Park" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.743332681963892, 40.738883099260399 ], [ -73.743713988889425, 40.739403248894853 ], [ -73.744015588350578, 40.740774866189021 ], [ -73.749902798306465, 40.73976600654369 ], [ -73.751451730302875, 40.74023415135968 ], [ -73.753493143641123, 40.742387881794677 ], [ -73.748442682670174, 40.743341445226534 ], [ -73.745734986748531, 40.742950378136875 ], [ -73.744764557218588, 40.743331686288812 ], [ -73.74647958037815, 40.746846320721609 ], [ -73.743763292184994, 40.747558590671638 ], [ -73.744102723836761, 40.748186334034315 ], [ -73.745663144082698, 40.751578016493404 ], [ -73.74602030834204, 40.752664410362485 ], [ -73.747505943390692, 40.7561384089299 ], [ -73.750462679159057, 40.759392209376529 ], [ -73.752421604502089, 40.760087609012793 ], [ -73.753477632863152, 40.75881302430551 ], [ -73.756450704981177, 40.758891576739906 ], [ -73.757978466699925, 40.758664933661294 ], [ -73.759777423030926, 40.757847640651867 ], [ -73.760671930361923, 40.7569937242137 ], [ -73.760726844374943, 40.755901992329967 ], [ -73.760150060011, 40.755049306932676 ], [ -73.760666168762725, 40.754874867708381 ], [ -73.76142135853749, 40.755744740117592 ], [ -73.761310971295984, 40.756962471795667 ], [ -73.761662988257086, 40.758149715625706 ], [ -73.760932794565818, 40.759031537050866 ], [ -73.759624705056396, 40.759219824299393 ], [ -73.758865446641437, 40.759942043958148 ], [ -73.758053875335492, 40.760126944837097 ], [ -73.757922346061648, 40.760424973893727 ], [ -73.758397858082262, 40.762008494965748 ], [ -73.756992424616044, 40.762274620569229 ], [ -73.750025013423993, 40.763748992665178 ], [ -73.7492870519647, 40.763087690904015 ], [ -73.746216707364937, 40.764225649907651 ], [ -73.744960350315637, 40.762153412361855 ], [ -73.74442168184261, 40.760490960815297 ], [ -73.742683787469147, 40.758785370498686 ], [ -73.740840519812664, 40.756008904636744 ], [ -73.739292080864331, 40.757054756789557 ], [ -73.739162077800728, 40.756295206272078 ], [ -73.739760303924498, 40.755444793786374 ], [ -73.740983257166647, 40.754872710421516 ], [ -73.741330739056906, 40.754592576436423 ], [ -73.741846841843682, 40.753465059940176 ], [ -73.741348074268771, 40.752469249095803 ], [ -73.740913211935975, 40.75198381387419 ], [ -73.739894590720326, 40.751337851053975 ], [ -73.738298235869266, 40.749221880773078 ], [ -73.737369133766208, 40.748345033193786 ], [ -73.736723225681644, 40.747917477529668 ], [ -73.735877647269263, 40.747527384898113 ], [ -73.735417990408877, 40.7471420011437 ], [ -73.735158325150621, 40.746556434443079 ], [ -73.73504353810857, 40.746115034424484 ], [ -73.735050664035469, 40.744874849546946 ], [ -73.734756046086432, 40.744117851372977 ], [ -73.733745601204006, 40.742838575876327 ], [ -73.733207502061873, 40.74179619089287 ], [ -73.733793821437558, 40.738987532501483 ], [ -73.738477269925554, 40.738116852534219 ], [ -73.740155366255252, 40.738531224294718 ], [ -73.741286528829264, 40.738813641081279 ], [ -73.743032264203379, 40.738441760123493 ], [ -73.743332681963892, 40.738883099260399 ] ] ] } }
...
4
  • 1
    You may get better results here if you include what actually happens other than "it doesn't work," such as error messages, unexpected output, etc... Commented Sep 23, 2014 at 16:35
  • Sure. It just leaves me in Ogr2ogr prompt (>). That's what I mean by it doesn't execute. Commented Sep 23, 2014 at 16:36
  • 2
    Ah, that's not an ogr2ogr prompt, that's your shell prompt asking for more input since you didn't properly escape your quotes. Look at the "Hell's Kitchen" part (but there may be more). How to properly escape those will depend on what shell you are using. Commented Sep 23, 2014 at 16:38
  • @EvilGenius Strangely, throwing an error for the output file. It shouldn't be trying to find this file, no? should be creating it. ERROR 3: Cannot open file 'subunits.json' FAILURE: Unable to open datasource `subunits.json' with the following drivers. -> ESRI Shapefile Commented Sep 23, 2014 at 16:46

2 Answers 2

2

You on Linux? If so, switch all the single quotes for double quotes and vice versa like this: ogr2ogr -f GeoJson -where 'neighborhood IN ("Lower East Side", "Greenwich Village", "Columbia St", "Financial District", "Flatiron District", "Williamsburg", "West Village", "Central Park", "Upper West Side", "Navy Yard", "Gramercy", "Stuyvesant Town", "Upper East Side", "Clinton Hill", "SoHo", "Bedford-Stuyvesant", "NoHo", "Vinegar Hill", "Theater District", "Park Slope", "Tribeca", "Chinatown", "Midtown", "Downtown Brooklyn", "Boerum Hill", "Kips Bay", "Hells Kitchen", "Chelsea", "Two Bridges", "Civic Center", "Murray Hill", "Brooklyn Heights", "Battery Park City", "Fort Greene", "East Village", "DUMBO", "Nolita")' output.json nyc-pediacities-neighborhoods-v3-polygon.geojson

3
  • This is in OS X Mav Bash terminal Commented Sep 23, 2014 at 17:09
  • 1
    Did you try switching it? Both comes from UNIX. Commented Sep 23, 2014 at 17:10
  • 1
    Just a btw: I spent like a day finding out why similar command was not working on Windows. The syntax you posted previously would be just fine for Windows, you need to switch quotes for UNIX systems though. Dunno why, but it works. Commented Sep 23, 2014 at 17:12
-1

That does not seem as valid geojson according to http://geojsonlint.com/. You should remove the last comma and add ]} to what you posted.

2
  • Oh... than I would go for replacing "Hells Kitchen"with 'Hells Kitchen'. Commented Sep 23, 2014 at 17:03
  • See it now, sorry I overlooked. Commented Sep 23, 2014 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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