I'm querying this map service using ogr2ogr to create a local copy of it's features: http://geoportal.menlhk.go.id/arcgis/rest/services/KLHK/Deforestasi_2006_2009/MapServer/0
Here's my ogr2ogr code, using where clause objectid > 0 to select everything:
ogr2ogr 2006_2009.geojson -f GEOJson "http://geoportal.menlhk.go.id/arcgis/rest/services/KLHK/Deforestasi_2006_2009/MapServer/0/query?where=objectid>0&outfields=*&f=json" OGRGeoJSON -gt 1000 -s_srs EPSG:3857 -t_srs EPSG:4326
My output (2006_2009.geojson) has 8724 features, which matches the record count here: http://geoportal.menlhk.go.id/arcgis/rest/services/KLHK/Deforestasi_2006_2009/MapServer/0/query?where=1%3D1&returnCountOnly=true&f=json
However, when I compare the shapefile in Arc with the shapefile in ArcOnline (coming directly from the source map server) I found the shapefile I created was missing features.

The reason I was seeing matching feature counts is because the ogr2ogr output has duplicate records:
ogrinfo 2006_2009.geojson OGRGeoJSON -dialect sqlite -sql "SELECT objectid, count(objectid) FROM OGRGeoJSON GROUP BY objectid HAVING (COUNT(objectid) > 1)"
The above query identifies 147 instances of duplicate objectids, suggesting that we're missing 147 records of real data given that the record counts match. Looking at the output dataset, I can see that there's nothing for objectids between 852 and 892. I can use ogr2ogr to extract these features successfully:
ogr2ogr -f GeoJSON missing_features.geojson "http://geoportal.menlhk.go.id/arcgis/rest/services/KLHK/Deforestasi_2006_2009/MapServer/0/query?where=objectid%3E852%20AND%20objectid%3C892&outFields=*&f=json" OGRGeoJSON -gt 1000 -s_srs EPSG:3857 -t_srs EPSG:4326
But for some reason these are not present in the original output, where the where clause selected all features with objectids > 0.
In sum, two issues:
- Why doesn't ogr2ogr export objectids 852 - 892 (and others) given a where clause of objectid > 0?
- More troubling-- why does it duplicate features to make the record counts equal?