USGS-VIZLAB / how-to-gdp

Explanation of how the Geo Data Portal works.
Creative Commons Zero v1.0 Universal
1 stars 4 forks source link

adding polygon to raster map #47

Closed lindsayplatt closed 6 years ago

lindsayplatt commented 6 years ago

Still not perfect....without adding the sp polygon, the raster map looks like this:

image

but then when I add it, it looks like this: image

There seems to be an issue with the projections because of the lat/long values are so different.

> sp::bbox(precip_sp_projected)
  min max
x   1  21
y   1  29
> sp::bbox(projected_sp)
      min       max
x  515163  554718.2
y 2252248 2304876.6
wdwatkins commented 6 years ago

@lindsaycarr projected_sp has to be in UTM coordinates, those aren't lat/lons

lindsayplatt commented 6 years ago

@wdwatkins yeah, I'm not really sure what that means or how to do that?

wdwatkins commented 6 years ago

Hmm, also the min/max you are getting for the raster I think is just the raster cell coordinates (ie it is 21x29 pixels). If you look at a map that won't be anywhere near WI.

Maybe see look into how the base raster is georeferenced?

wdwatkins commented 6 years ago

It looks fairly simple to transform from UTM to lat/lon if you need to. https://stackoverflow.com/questions/36520915/converting-utms-to-lat-long-in-r

lindsayplatt commented 6 years ago

OK, so I looked at this page (https://gis.stackexchange.com/questions/23841/create-a-raster-with-georeferenced-information-in-r) and realized I had the exact extent of the raster in order to georeference it to lat/long, so I added that step. I'm much closer because the watershed polygon plots over the same region, but now the precip values don't show up:

image

wdwatkins commented 6 years ago

Good progress, is there a white background with the polygon maybe?

lindsayplatt commented 6 years ago

There was something strange happening with re-projecting it. Something about warping. I kept it in the projection string that geoknife automatically uses and it works:

image

lindsayplatt commented 6 years ago

@wdwatkins can you do another quick review? I can run make and this is what I get for the clip fig:

image

wdwatkins commented 6 years ago

If you're dealing with cosmetic stuff yet I would say reduce the color scale range so it is all used, unless there will be other maps with values that go to two, and make the legend about twice as big. Will look at the code later this morning.

lindsayplatt commented 6 years ago

Well, the maximum value is 1.8 ... so I had the scale round up from the maximum. What's the best way to do it?

wdwatkins commented 6 years ago

Oh ok, never mind then. It must just be a single cell or something.

lindsayplatt commented 6 years ago

They all look faded though, like alpha is not 1. I haven't figured that out.

lindsayplatt commented 6 years ago

Hmm yep - that's the issue. I thought I had that working for something previously? I'll submit changes to that and then merge this! Thanks!

lindsayplatt commented 6 years ago

Here's what it looks like now (still not included in publish)

image