Hi Josh,
Do you have the PyShp Python package installed in the
Python being used by PyFerret?
The SHAPEFILE_... functions use this package to do the
actual reading and writing of the shapefile files.
The PyShp package (see:
https://pypi.org/project/pyshp/ )
is pure Python code and can be installed using "pip" or
(possibly) through your system's package manager (I have seen
the packages names pyshp and python-pyshp)
The following is to help clarify using the SHAPEFILE_READXY
function. I downloaded the 2010 US Counties shapefile, which
actually is the following files:
tl_2010_us_county10.dbf
tl_2010_us_county10.prj
tl_2010_us_county10.shp
tl_2010_us_county10.shp.xml
tl_2010_us_county10.shx
I am able to read and work with this shapefile using the
ferret commands.
set mem /size=500
let uscounties =
shapefile_readxy("tl_2010_us_county10", 7560000)
load /perm uscounties
let uscounties_poslon = if uscounties ge 0.0 then
uscounties else 360.0 + uscounties
plot /line=7 /vs /hlimits=235:250 /vlimits=42:50
uscounties_poslon[j=1],uscounties[j=2]
frame /file=uscounties_test.png
I happen to know there are no more that 7560000 coordinates
so the function call returns immediately (without reading
anything). Iif you did not know the count, you can use -1 and
it will do an initial read of the shapefile to get the number
of coordinates (so it will take awhile to do the initial
read). You may need to increase the amount of allowed memory
(as was done here) if you are reading a large shapefile. Note
that shapefile coordinates are just numbers, not necessarily
longitude and latitude. The .prj file is there to explain
these numbers, but I do not know how much the PyShp package
makes use of this file. The returned value is an array of X,Y
coordinates, where X values are at [J=1] and Y values are at
[J=2]. The plot in this example is just an ordinary X-Y plot
(after adjusting the X values - which happen to be longitudes
in this case - to positive values).
Karl
Karl M. Smith, Ph.D.
JISAO Univ. Wash. and PMEL NOAA
"The contents of this message are mine personally and do
not necessarily reflect any position of the Government
or the National Oceanic and Atmospheric Administration."