-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pycoast v0.5.2 issue when drawing coastlines #23
Comments
I know this is old, but what is the actual version pycoast version at fault here? The current version released is 1.2.1. |
Ah it is 0.5.2 as mentioned in the linked google thread. |
Could someone (@sassimarco, @peters77, ?) make a self-contained example for this one? I just merged some stuff to master that handles thresholds better, but this was really only intended for some pyproj changes. Probably not going to fix this, but hard to tell without an example that doesn't require outside data. |
Hi Dave,
here an example, quite an old implementation....
[image: image.png]
dask==1.0.0
h5netcdf==0.5.0
h5py==2.8.0
netCDF4==1.4.2
numpy==1.15.2
pandas==0.23.4
path.py==11.0
Pillow==5.2.0
pycoast==1.1.0
pykdtree==1.3.1
pyninjotiff==0.1.0
pyproj==1.9.5.1
pyresample==1.10.3
pyshp==1.2.12
pyspectral==0.8.3
python-dateutil==2.7.3
python-geotiepoints==1.1.6
pytz==2018.5
PyYAML==3.13
requests==2.19.1
satpy==0+unknown
scipy==1.1.0
six==1.11.0
toolz==0.9.0
trollimage==1.5.7
trollsift==0.2.1
urllib3==1.23
xarray==0.11.0
…On Fri, 6 Dec 2019 at 21:42, David Hoese ***@***.***> wrote:
Could someone ***@***.*** </~https://github.com/sassimarco>, @peters77
</~https://github.com/peters77>, ?) make a self-contained example for this
one? I just merged some stuff to master that handles thresholds better, but
this was really only intended for some pyproj changes. Probably not going
to fix this, but hard to tell without an example that doesn't require
outside data.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#23?email_source=notifications&email_token=AK2I2LZNNARGVLZR5IS5QYTQXK2KHA5CNFSM4GGUMDXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGFJJBY#issuecomment-562730119>,
or unsubscribe
</~https://github.com/notifications/unsubscribe-auth/AK2I2LYSQ2U6DHTQ62SAUC3QXK2KHANCNFSM4GGUMDXA>
.
|
@sassimarco I don't think github liked you sending an image over email. You may have to add the image directly from the github page. If you have the code as text that I can copy and paste that would be the best kind of example. |
|
I was kind of hoping for a simple example (15 lines?). I'm hoping that the data can be randomly generated with |
in that case these are the lines...
|
Thanks! FYI I updated your last two comments. The code blocks need to have three backticks before and after the code. The three backticks have to be on their own lines though (no code on those lines). |
@sassimarco what's the area definition you use ? Can you paste it here ? |
Ciao Martin,
ok, i found it out in a old GOES17 Script.....
areaid = 'NinJoGOESWregion'
areadef = get_area_def(areaid)
REGION: NinJoGOESEregion {
NAME: NinJoGOESEregion
PCS_ID: NinJoGOESEregion
PCS_DEF: proj=eqc, lon_0=-75.2, ellps=WGS84
XSIZE: 2500
YSIZE: 2500
AREA_EXTENT:
(-10008769.814946,-10016778.695711,10016778.695711,10008768.924390)
};
REGION: NinJoGOESWregion {
NAME: NinJoGOESWregion
PCS_ID: NinJoGOESWregion
PCS_DEF: proj=eqc, lon_0=-137.2, a=6378137.00
XSIZE: 2500
YSIZE: 2500
AREA_EXTENT:
(-10008769.814946,-10016778.695711,10016778.695711,10008768.924390)
};
Marco
…On Fri, 21 Feb 2020 at 12:12, Martin Raspaud ***@***.***> wrote:
@sassimarco </~https://github.com/sassimarco> what's the area definition
you use ? Can you paste it here ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#23?email_source=notifications&email_token=AK2I2L7NN7WVIVYIGWNQJITRD6ZLHA5CNFSM4GGUMDXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMSLYQY#issuecomment-589610051>,
or unsubscribe
</~https://github.com/notifications/unsubscribe-auth/AK2I2L25EUGX5MVGZKVCVQTRD6ZLHANCNFSM4GGUMDXA>
.
|
Thanks. |
Related: pytroll/satpy#1224 contains a MCVE that with pytroll/satpy@aed86fd reproduces the problem (a roundabout way, but still) when reading an ICON GRIB file: from satpy import Scene
from glob import glob
sc = Scene(filenames={"grib":
glob("/media/nas/x21308/scratch/ICON/*12:00:00Z*000.grib")})
sc.load(["t"])
sc.show("t", overlay={"coast_dir": "/media/nas/x21308/shp/", "color": "red"}) which with the linked pull request gives |
Hi there, I tried to draw coastline for the given area definition and found this issue as well. Is there an existing way to get around it? Thanks Here are my area definition and script. areas.yaml
|
Thanks for the example @yzhan-met. I simplified it a bit with modern pyresample so it doesn't require the extra YAML: import pyresample
from PIL import Image
from pycoast import ContourWriterAGG
cw = ContourWriterAGG('/data/gshhg_shapefiles')
img = Image.new('RGB', (425, 425))
area_def = pyresample.create_area_def(
"test",
"+proj=merc +lat_0=-13.5 +lon_0=177.5 +ellps=WGS84",
width=425, height=425,
area_extent=[-4175000, -4140170, 4175000, 1097830],
)
cw.add_coastlines(img, area_def, resolution='i')
img.show() We've had a user on the mailing list come up with a workaround: --- cw_base.py.dist 2021-08-18 17:14:34.000000000 +0000
+++ cw_base.py 2022-03-11 09:41:04.664157608 +0000
@@ -593,9 +593,14 @@
# Check if polygon is possibly relevant
s_lon_ll, s_lat_ll, s_lon_ur, s_lat_ur = shape.bbox
- shape_is_outside_lon = lon_max < s_lon_ll or lon_min > s_lon_ur
+ if lon_min <= lon_max:
+ # Area_extent west or east of dateline
+ shape_is_outside_lon = lon_max < s_lon_ll or lon_min > s_lon_ur
+ else:
+ # Area_extent spans over dateline
+ shape_is_outside_lon = lon_max < s_lon_ll and lon_min > s_lon_ur
shape_is_outside_lat = lat_max < s_lat_ll or lat_min > s_lat_ur
- if lon_min <= lon_max and (shape_is_outside_lon or shape_is_outside_lat):
+ if shape_is_outside_lon or shape_is_outside_lat:
# Polygon is irrelevant
continue This doesn't solve every case of lines going across the image but it certainly helps. I just wanted to record this somewhere other than the mailing list in case people had other ideas or other solutions. I also plan on bringing up other ideas with the user on the mailing list. |
Reference to similar problem in Google Group:
https://groups.google.com/forum/#!searchin/pytroll/pycoast$20lines%7Csort:date/pytroll/tzmtaDuaGD4/kVrY2RZ93gEJ
Hrobjartur Thorsteinsson:
Coastlines need a consistency check that drawn line-segments do not exceed some sort of threshold. We had considered that, but now I think I should add that improvement.
The text was updated successfully, but these errors were encountered: