I am trying to preprocess a netcdf dataset with arcgis such that it has the same extent, cellsize and format as an ascii dataset I am using. Both are visualized in the image below: netcdf and ascii dataset The big one in grey is the netcdf dataset, it has a longitude range of 0-360. The small dataset in Black is ascii, it has a range of -180-+180 decimal degrees. Problem is, the netcdf dataset is split right at the greenwich meridian, which splits africa, my region of interest. Now, i can change the prime meridian in the dataset to -180°, which makes the image look right, and both layers are congruent. Problem is, I want to clip the large dataset with the extent of the small dataset (rectangular), but since the minimal X is -30, the clipped image is cut exactly at 0 degrees. I tried to shift the whole dataset to the left (X-180°) but then again, it cuts off at 0°

Thanks for the help

  • Generally you need to crop one half and shift that, or use a projection that spans the region of interest, but how you do that depends on the software. Is arcgis part of the question, or are other options of interest? – mdsumner Nov 14 '13 at 22:26
  • yea, thats exactly what i have done many times with arcgis, but then the clipping messes up and contains only one half. I would VERY much appreciate other options. I am trying gdal_translate right now, but i'm stuck at merging the two tifs (can't get merge python script to work...) – user2160180 Nov 14 '13 at 22:34
  • Thank you very much, I'm still not done testing the whole preprocessing, but I've gotten gdal_translate to work like there: eloiribeiro.wordpress.com/2009/07/08/… Since it's in portuguese I'll add a small english howto as an answer later on – user2160180 Nov 15 '13 at 9:37

Ok, so here is what did the trick. I used this approach: http://eloiribeiro.wordpress.com/2009/07/08/coverter-imagens-0%C2%BA-360%C2%BA-a-180-180%C2%BA-com-gdal/ It swaps the hemispheres via gdal_translate, and therefore transforms the longitude range from 0°-360° to -180°-+180°. A quick english summary:

gdal_translate -srcwin 0 0 360 360 -a_ullr 0 90 180 -90 input output
gdal_translate -srcwin 360 0 360 360 -a_ullr -180 90 0 -90 input output

The -srcwin variables are the outer limits of the hemisphere you want to swap, the unit here is the number of cells in your source image. In my case, the left hemisphere starts in the origin with 0/0. The lower right corner is at 360/360, with 360 being half the cellcount in x direction and the entire cell count in y direction (the image has 720*360 cells). The -a_ullr coordinates are the extent of your destination (the right hemispere in this case), but this time the unit is decimal degrees. Once the images are swapped, they can be merged with gdal_merge.py, the exact input being:

python gdal_merge.py -o output input1 input2

One quick addition: The whole process messed with my NoData values, and I had to replace them manually with arcpy setnull, so please don't lose it if the images look strange/black at first glance.

Thx for all the effort guys!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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