Open dslosky-usgs opened 4 years ago
You can probably handle this by normalizing the coordinates around the epicenter, so longitudes are consistent. If event longitude is +, normalize all values to be [0,360); if event longitude is -, normalize all values to be (-360,0]. For the image overlay, something like:
if (maxlon < minlon) {
maxlon += 360;
}
This was an issue in geojson and @cbworden implemented something to handle this shift. For this event, all longitudes seem to use the - coordinate system even though epicenter is +. This results in contours plotting on "wrong" side of map instead of with epicenter.
I'm not sure I understand what you mean by "all longitudes". From where are you obtaining the longitudes? The overlay png looks okay, and the png world file correctly gives the upper left corner of the plot and the dx increment is positive and the dy is negative. What needs to change to make the overlay work?
Looking in the event feed: https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=us1000778i&format=geojson
The shakemap product reports:
"maximum-longitude": "-179.65
"minimum-longitude": "165.633",
The image overlay is stretched and reversed because of this. Daniel can probably update the referenced coordinates so the overlay is shown correctly, or they could be updated for internal consistency before sending the product: https://earthquake.usgs.gov/earthquakes/eventpage/us1000778i/shakemap/intensity
MMI contours file uses negative coordinates, even though the epicenter longitude is reported as (+)173.054. When selecting contours they are plotted on the "other" side of the map at the left edge.
-194.366667,
-47.216771,
-179.68322,
-36.65
Coverage JSON is consistent with epicenter longitude and looks good:
"start": 165.63333333333333,
"stop": 180.29999999999998,
"num": 111
I guess I'm lost. It seems like in one case longitudes that go beyond +/-180 are okay, and in the other they are not. Is everything relative to the epicenter, or are longitudes absolute? Why is -179 different from 181? And when?
So, if my epicenter is 179.0 and the map spans 4 degrees (+/- 2 degrees on either side of the epicenter), what are its max/min longitudes? And if the epicenter is -179.0, what are its max/min longitudes? For everything. The properties, the contours, the stations, everything.
The main problem is when we use the data in leaflet. It's longitudes continue, but it only wraps at 360 instead of 180.
Using coordinates that are close to the reported epicenter helps keep all the data in a similar view. So if the epicenter was at +179, use coordinates [+177, +181]; for -179, use coordinates[-181, -178]; etc. It's okay if the values extend beyond +/- 180 as long as they are centered on the epicenter. Generally this should keep longitudes within (-360,360] and better to be consistent even if there's a little overflow.
There's a whole other issue if the origin is on one side, and shakemap on the other, but it's much easier to shift individual points than polygons with many points.
Okay, thanks. I'll go through the code and try to keep things consistent with the epicenter. If only the world was flat this would all be easier.
Are we reasonably safe at the zero line? So, e.g., if the min longitude is -2 and the max is +2 I can leave it?
yes, because those are both close to zero.
Checkout us1000778i