{"action":"created","issue":{"url":"https://api.github.com/repos/ozak/georasters/issues/18","repository_url":"https://api.github.com/repos/ozak/georasters","labels_url":"https://api.github.com/repos/ozak/georasters/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/ozak/georasters/issues/18/comments","events_url":"https://api.github.com/repos/ozak/georasters/issues/18/events","html_url":"https://github.com/ozak/georasters/issues/18","id":211902307,"number":18,"title":"Aggregate/Align example","user":{"login":"apiszcz","id":1430861,"avatar_url":"https://avatars1.githubusercontent.com/u/1430861?v=3","gravatar_id":"","url":"https://api.github.com/users/apiszcz","html_url":"https://github.com/apiszcz","followers_url":"https://api.github.com/users/apiszcz/followers","following_url":"https://api.github.com/users/apiszcz/following{/other_user}","gists_url":"https://api.github.com/users/apiszcz/gists{/gist_id}","starred_url":"https://api.github.com/users/apiszcz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apiszcz/subscriptions","organizations_url":"https://api.github.com/users/apiszcz/orgs","repos_url":"https://api.github.com/users/apiszcz/repos","events_url":"https://api.github.com/users/apiszcz/events{/privacy}","received_events_url":"https://api.github.com/users/apiszcz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-04T19:45:00Z","updated_at":"2017-03-04T20:34:39Z","closed_at":null,"body":"I am attempting to perform the following\r\n1. Reduce cell size by a factor of 10\r\n2. Align two images with different extents\r\n3. Ideally SUM values of each\r\n4. I am getting a broadcast error stating the images are not equivalent in size.\r\n5. I am unsure how the alignment return values are used.\r\n\r\n```\r\nf1='file1.tif'\r\nf2='file2.tif'\r\n\r\ndata1t=gr.load_tiff(f1)\r\ndata2t=gr.load_tiff(f2)\r\n\r\nNDV, xsize, ysize, GeoT, Projection, DataType = gr.get_geo_info(f1)\r\ndata1ta=gr.aggregate(data1t,NDV,(10,10))\r\ndata2ta=gr.aggregate(data2t,NDV,(10,10))\r\n\r\ndriver = gdal.GetDriverByName('GTiff')\r\ndriver.Register()\r\nNoDataValue=0.0\r\nGeoT=list(GeoT)\r\nGeoT[1]=GeoT[1]*10\r\nGeoT[5]=GeoT[5]*10\r\n\r\nd1fname=gr.create_geotiff('test1d',data1ta,driver,NoDataValue,data1ta.shape[1], data1ta.shape[0], GeoT, Projection, DataType)\r\nd2fname=gr.create_geotiff('test2d',data2ta,driver,NoDataValue,data2ta.shape[1], data2ta.shape[0], GeoT, Projection, DataType)\r\n\r\n# Agregate raster by summing over cells in order to increase pixel size by e.g. 10\r\n(alignedraster_o, alignedraster_a, GeoT_a) = gr.align_rasters(d1fname, d2fname, how=np.sum)\r\n\r\ndata1t=gr.load_tiff('test1d.tif')\r\ndata2t=gr.load_tiff('test2d.tif')\r\n\r\nA=gr.GeoRaster(data1t, GeoT, nodata_value=NDV)\r\nNDV, xsize, ysize, GeoT, Projection, DataType = gr.get_geo_info('test1d.tif')\r\nA.projection=Projection\r\nB=gr.GeoRaster(data2t, GeoT, nodata_value=NDV)\r\nB.projection=Projection\r\nC=B.merge(A)\r\n\r\nmergedname=gr.create_geotiff('test_merged',C,driver,NoDataValue,alignedraster_o.shape[1], alignedraster_o.shape[0], GeoT_a, Projection, DataType\r\n```\r\n\r\n\r\n`ValueError: operands could not be broadcast together with shapes (138,166) (138,166) (118,166)`"},"comment":{"url":"https://api.github.com/repos/ozak/georasters/issues/comments/284178922","html_url":"https://github.com/ozak/georasters/issues/18#issuecomment-284178922","issue_url":"https://api.github.com/repos/ozak/georasters/issues/18","id":284178922,"user":{"login":"ozak","id":650534,"avatar_url":"https://avatars1.githubusercontent.com/u/650534?v=3","gravatar_id":"","url":"https://api.github.com/users/ozak","html_url":"https://github.com/ozak","followers_url":"https://api.github.com/users/ozak/followers","following_url":"https://api.github.com/users/ozak/following{/other_user}","gists_url":"https://api.github.com/users/ozak/gists{/gist_id}","starred_url":"https://api.github.com/users/ozak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ozak/subscriptions","organizations_url":"https://api.github.com/users/ozak/orgs","repos_url":"https://api.github.com/users/ozak/repos","events_url":"https://api.github.com/users/ozak/events{/privacy}","received_events_url":"https://api.github.com/users/ozak/received_events","type":"User","site_admin":false},"created_at":"2017-03-04T20:34:39Z","updated_at":"2017-03-04T20:34:39Z","body":"@apiszcz I am not sure if I misunderstand or if what you were trying to do is not in the code you wrote. \r\n\r\n1. Reduce cell size by a factor of 10: Do you mean you want to decrease the number of cells by 10 or the actual cell size? the ``aggregate`` function is intended for the first, not the second. I am not the other can be performed with the current functions. \r\n\r\n2. Align two images with different extents: You should be getting the two rasters aligned with the command ``(alignedraster_o, alignedraster_a) = data1t.align(data1t, how=np.sum)`` if you intend to sum the cells otherwise choose the function of how you would like to treat the cells.\r\n\r\n3. Ideally SUM values of each: Do you mean ``alignedraster_o + alignedraster_a``? Or summing the cells? See 2.\r\n\r\nLet me know if this helps. Otherwise can you share the rasters and a clearer description of what you are trying to accomplish.\r\n"}}
{"actor":{"display_login":"ozak"}}