CHLNDDEV / OceanMesh2D

A two-dimensional triangular mesh generator with pre- and post-processing utilities written in pure MATLAB (no toolboxes required) designed specifically to build models that solve shallow-water equations or wave equations in a coastal environment (ADCIRC, FVCOM, WaveWatch3, SWAN, SCHISM, Telemac, etc.).
https://github.com/sponsors/krober10nd
GNU General Public License v3.0
179 stars 65 forks source link

error reading shape file #211

Closed chenfsu closed 3 years ago

chenfsu commented 3 years ago

I am trying to read a shapefile using the code below.

file41='jia_24_newFishnet3_Intersect'; Res41=1; shp41=geodata('shp',file41,'bbox',bbox,'h0',Res41);

It can read other shapefiles without problem, but this file may be a little trick, and it gives error info as below. Any suggestions or comments are welcomed. Thanks!

Reading shapefile with m_shaperead 8584 Records in file, by 500:

.................Partitioning the boundary into islands, mainland, ocean Index in position 1 exceeds array bounds (must not exceed 2).

Error in Read_shapefile (line 149) tmpCC{nn,1} = tmpC{ii,1}(is:ie,:);

Error in geodata/ParseShoreline (line 322) polygon_struct = Read_shapefile( obj.contourfile, [], ...

Error in geodata (line 284) obj = ParseShoreline(obj) ;

krober10nd commented 3 years ago

Hey @chenfsu

Thanks for letting us know. Could you provide us with a bit more information such as the what version of OM you're using (latest commit number) and if possible share the shapefile so I can test on it my system?

Relatively recently we fixed an issue where some shapefiles were mistakenly being read in as 3D polygons. This could perhaps be the issue and in that case simply updating the software would solve the issue.

chenfsu commented 3 years ago

Thank you, Keith. I am using the version that I pulled on April 1st. The latest commit number should be: 315693e64ffee56cd9c8dbb503ff7f180c8726c0

Yes, I can share the shapefile, it's attached here. I do see this shapefile has Z values and M values from ArcGIS. The other ones doesn't have the Z values and M values can be read by OM without an error. Thanks!

On Sat, Apr 10, 2021 at 1:37 PM Keith Roberts @.***> wrote:

Hey @chenfsu https://github.com/chenfsu

Thanks for letting us know. Could you provide us with a bit more information such as the what version of OM you're using (latest commit number) and if possible share the shapefile so I can test on it my system?

Relatively recently we fixed an issue where some shapefiles were mistakenly being read in as 3D polygons. This could perhaps be the issue and in that case simply updating the software would solve the issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CHLNDDEV/OceanMesh2D/issues/211#issuecomment-817176169, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFY2GVZLBWMXBUFC3QWK6LTICEEZANCNFSM42WWZBPA .

-- Xu Chen Post Doctoral Scientist Center for Ocean-Atmospheric Prediction Studies (COAPS) Florida State University 2000 Levy Avenue, Suite 292 | Research Building A Tallahassee, FL 32306 Email: @.*** Phone: (850) 320-5117

chenfsu commented 3 years ago

The shapefile is attached here:

FSU Dropbox-QgSW7ApsXY3wfpiZ.zip https://drive.google.com/file/d/1pCZCaaxHET0T4sRkMFqm_pNtGr24LUv2/view?usp=drive_web

On Sat, Apr 10, 2021 at 1:37 PM Keith Roberts @.***> wrote:

Hey @chenfsu https://github.com/chenfsu

Thanks for letting us know. Could you provide us with a bit more information such as the what version of OM you're using (latest commit number) and if possible share the shapefile so I can test on it my system?

Relatively recently we fixed an issue where some shapefiles were mistakenly being read in as 3D polygons. This could perhaps be the issue and in that case simply updating the software would solve the issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CHLNDDEV/OceanMesh2D/issues/211#issuecomment-817176169, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFY2GVZLBWMXBUFC3QWK6LTICEEZANCNFSM42WWZBPA .

-- Xu Chen Post Doctoral Scientist Center for Ocean-Atmospheric Prediction Studies (COAPS) Florida State University 2000 Levy Avenue, Suite 292 | Research Building A Tallahassee, FL 32306 Email: @.*** Phone: (850) 320-5117

krober10nd commented 3 years ago

Thanks what's bbox in your problematic case?

krober10nd commented 3 years ago

and h0?

chenfsu commented 3 years ago

Sorry.

bbox=[-85.2868533 -84.5421920; 29.5624907 30.0699572]; % DEM

h0=1;

On Sat, Apr 10, 2021 at 2:10 PM Keith Roberts @.***> wrote:

and h0?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CHLNDDEV/OceanMesh2D/issues/211#issuecomment-817180929, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFY2GRJT4IKEPIQ7PXXR3LTICH75ANCNFSM42WWZBPA .

-- Xu Chen Post Doctoral Scientist Center for Ocean-Atmospheric Prediction Studies (COAPS) Florida State University 2000 Levy Avenue, Suite 292 | Research Building A Tallahassee, FL 32306 Email: @.*** Phone: (850) 320-5117

krober10nd commented 3 years ago

Okay, I replicated the error. It appears to have a z-dimension

Error using openShapeFiles>readHeaderTypeCode (line 145)
Unsupported shape type PolyLineZ (type code = 13).

Error in openShapeFiles (line 23)
headerTypeCode = readHeaderTypeCode(shpFileId,callingFcn);

Error in shaperead (line 210)
    = openShapeFiles(filename,'shaperead');

I converted it to a 2D shapefile like this

 ogr2ogr -f "ESRI Shapefile" output_2d.shp jia_24_newFishnet4_Intersect.shp -dim 2 

and then re-ran this

shp41=geodata('shp','output_2d','bbox',bbox,'h0',1);

then got this

Screen Shot 2021-04-10 at 3 33 44 PM
krober10nd commented 3 years ago

I would recommend first starting with 5 or 10 resolutions for the h0 parameter. This looks like quite a complex geometry.

chenfsu commented 3 years ago

Thank you very much, Keith! really appreciate it!

On Sat, Apr 10, 2021 at 2:35 PM Keith Roberts @.***> wrote:

I would recommend first starting with 5 or 10 resolutions for the h0 parameter. This looks like quite a complex geometry.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CHLNDDEV/OceanMesh2D/issues/211#issuecomment-817184711, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFY2GWURRUW6SM5GVYMBOTTICK7TANCNFSM42WWZBPA .

-- Xu Chen Post Doctoral Scientist Center for Ocean-Atmospheric Prediction Studies (COAPS) Florida State University 2000 Levy Avenue, Suite 292 | Research Building A Tallahassee, FL 32306 Email: @.*** Phone: (850) 320-5117

krober10nd commented 3 years ago

No problem! Not sure if that will work to mesh with. The shapefile appears to contain millions of small unconnected line segments.

chenfsu commented 3 years ago

I used a similar shapefile, it works with the "channel" method in edgefx. I use this approach to make some specific features have a uniform resolution. Hope this one will also work. Thank you! And thank you for coding this great software and making it free :)

On Sat, Apr 10, 2021 at 2:51 PM Keith Roberts @.***> wrote:

No problem! Not sure if that will work to mesh with. The shapefile appears to contain millions of small unconnected line segments.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/CHLNDDEV/OceanMesh2D/issues/211#issuecomment-817186597, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFY2GUOMFDGK4T2CLE42HLTICM2FANCNFSM42WWZBPA .

-- Xu Chen Post Doctoral Scientist Center for Ocean-Atmospheric Prediction Studies (COAPS) Florida State University 2000 Levy Avenue, Suite 292 | Research Building A Tallahassee, FL 32306 Email: @.*** Phone: (850) 320-5117

krober10nd commented 3 years ago

Creative! Good luck. Well close this issue if you figure everything out otherwise we can keep it open and wait and see.

chenfsu commented 3 years ago

Yes, I will close it. Thanks!