MapWindow 4 - ActiveX Control Programming : MapWindow Discussion Forum
hi friends , i work on a project that i very need to clip method in shapefile but this method return null always , i give it 2 maps , one my majore map and secound map that have one shape , i give them to arcmap and map window gis 4 and work very well but in programing it doesn't work and always r
a probleme with clip shapefile with polygone
Posted by: ahmad_ferdinand ()
Date: March 17, 2012 01:02AM

hi friends , i work on a project that i very need to clip method in shapefile but this method return null always , i give it 2 maps , one my majore map and secound map that have one shape , i give them to arcmap and map window gis 4 and work very well but in programing it doesn't work and always return null
this is my code ,


main_map = new Shapefile();
dest = new Shapefile();
source = new Shapefile();

main_map.Open(openFileDialog2.FileName, null);
source.Open(@"C:\Users\laptop\Desktop\ahmad\nahie.shp", null);
source.set_ShapeSelected(0, true);
dest = main_map.Clip(true, source, false);

dest.SaveAs("d:\\clip.shp", null);

if friends help me i be thankful .

Options: ReplyQuote
Re: a probleme with clip shapefile with polygone
Posted by: ahmad_ferdinand ()
Date: March 18, 2012 04:30AM

friends please , i very need help

Options: ReplyQuote
Re: a probleme with clip shapefile with polygone
Posted by: ahmad_ferdinand ()
Date: March 18, 2012 07:44AM

pleasessssssssssssssssssssssss.............. helip meeeeeeeeeeeeeeeee

Options: ReplyQuote
Re: a probleme with clip shapefile with polygone
Posted by: pmeems ()
Date: March 19, 2012 01:56AM

You need to be more patient.
We are all volunteers in different time zones.

You need to use Utils.ClipPolygon() or use Shapefile.Clip().

Look at the documentation for more help: [www.mapwindow.org]

--
Don't forget to read the new documentation: www.mapwindow.org/documentation/mapwingis4.8
Join us Google+: MapWindow GIS Google+ Community
Join the MapWindow Group on LinkedIn! LinkedIn - MapWindow Group

Download the latest beta installer at:
tinyurl.com/mwMonthly 32-Bit
tinyurl.com/mwMonthlyx64 64-Bit
Follow me on Twitter MapWindow_nl to read when a new installer is published.

---
Paul Meems
The Netherlands
[www.bontepaarden.nl]
Release manager, configuration manager and
forum moderator of MapWindow GIS

Owner of MapWindow.nl - Support for
Dutch speaking users: www.mapwindow.nl

*******
Everything I say or write is my personal opinion and
not the opinion of the company I work for.
*******
View my profile on LinkedIn

Options: ReplyQuote
Re: a probleme with clip shapefile with polygone
Posted by: smo ()
Date: March 19, 2012 07:37AM

Hello,

I have the same issue on some shapefiles. Utils.ClipPolygon or Shapefile.Clip returned "nothing" (VB6) even if the clip operation should work. In this case I can't do any clip operation, they all returned "nothing". Even Union operation that should always return something.

---
Sorry for my bad english, I am not a specialist in the foreign languages... ;)

Options: ReplyQuote
Re: a probleme with clip shapefile with polygone
Posted by: ahmad_ferdinand ()
Date: March 19, 2012 08:25AM

thank you pmeems , but utils.clip() do same work with shapefile.clip()?
i don't think , because utils.clip only return one shape and clip command maybe return many shapes that all of this shapes must be save in a shapefile , just shapefile.clip() do this work that in many time return null,
if you have more information about clip please help , thanks

Options: ReplyQuote
Re: a probleme with clip shapefile with polygone
Posted by: pmeems ()
Date: March 19, 2012 09:13AM

You can try first with the Desktop version of MapWindow.
The clipping tool is in Toolbox --> Vector Operations --> Clipping.

If that is producing the expected result your code might be wrong.
If you post your code here we can have a look (don't forget to use the [code ] tags!)

--
Paul

--
Don't forget to read the new documentation: www.mapwindow.org/documentation/mapwingis4.8
Join us Google+: MapWindow GIS Google+ Community
Join the MapWindow Group on LinkedIn! LinkedIn - MapWindow Group

Download the latest beta installer at:
tinyurl.com/mwMonthly 32-Bit
tinyurl.com/mwMonthlyx64 64-Bit
Follow me on Twitter MapWindow_nl to read when a new installer is published.

---
Paul Meems
The Netherlands
[www.bontepaarden.nl]
Release manager, configuration manager and
forum moderator of MapWindow GIS

Owner of MapWindow.nl - Support for
Dutch speaking users: www.mapwindow.nl

*******
Everything I say or write is my personal opinion and
not the opinion of the company I work for.
*******
View my profile on LinkedIn

Options: ReplyQuote
Re: a probleme with clip shapefile with polygone
Posted by: smo ()
Date: March 21, 2012 05:36AM

Hello,

I've tried with the Desktop version of MapWindow and I have the same issue.
Clipping doesn't work on some shapes of some shapefiles.

for example, if I have two shapefiles (shapefile1 and shapefile2) and try to make the union of the two shapefiles, the result exclude some shapes as if they doesnt' exist !
The result is not the union of shapefile1 and shapefile2 but the union of shapefile1 and some shapes of shapefile2 !

If I try to clip this particular shapes (of shapefile2) with shapefile1 (or some shapes of shapefile1), this doesn't work at all and Mapwindow show a messagebox "No result was returned. No Error".

I attached a zip file containing two shapefiles :
- "parcelle" that contains lots of shapes
- "lot_chasse" that contains two big shapes.

I can clip one the shapes of "lot_Chasse" (shapefile index=1) with "parcelle" but not the other (shapefile index=0) !

---

If I use the "validate shapefile" tool it seems that my faulty shapefile has "Self-intersection" error.

---
Sorry for my bad english, I am not a specialist in the foreign languages... ;)



Edited 1 time(s). Last edit at 03/21/2012 05:49AM by smo.

Attachments: bug_clipping.zip (126.4 KB)  
Options: ReplyQuote
Re: a probleme with clip shapefile with polygone
Posted by: pmeems ()
Date: March 21, 2012 07:12AM

What happens if you first repair the invalid shapes using the Fix tool in the toolbox and perform the union on the two repaired shapefiles?

I just did it and it seems to me it is working.

In the next version of MapWindow the Union tool will try to repair invalid shapes first before doing the union.

--
Paul

--
Don't forget to read the new documentation: www.mapwindow.org/documentation/mapwingis4.8
Join us Google+: MapWindow GIS Google+ Community
Join the MapWindow Group on LinkedIn! LinkedIn - MapWindow Group

Download the latest beta installer at:
tinyurl.com/mwMonthly 32-Bit
tinyurl.com/mwMonthlyx64 64-Bit
Follow me on Twitter MapWindow_nl to read when a new installer is published.

---
Paul Meems
The Netherlands
[www.bontepaarden.nl]
Release manager, configuration manager and
forum moderator of MapWindow GIS

Owner of MapWindow.nl - Support for
Dutch speaking users: www.mapwindow.nl

*******
Everything I say or write is my personal opinion and
not the opinion of the company I work for.
*******
View my profile on LinkedIn

Options: ReplyQuote
Re: a probleme with clip shapefile with polygone
Posted by: ahmad_ferdinand ()
Date: March 21, 2012 10:17AM

thank you for particition
this is my code it is so simple


            main_map = new Shapefile();
            dest = new Shapefile();
            source = new Shapefile();
            
            main_map.Open(openFileDialog2.FileName, null);
            source.Open(@"C:\Users\laptop\Desktop\ahmad\nahie.shp", null);
            source.set_ShapeSelected(0, true);
            dest = main_map.Clip(true, source, false);

          
            dest.SaveAs("d:\\clip.shp", null);

main map open with open file dialoge and secound that have just one shape , igave it's path , in map windows 4 , i go to toolbox/old tools/clip shapefile with polygon/ , it gives a shapefile with many shape and a shape file with one shape just, just in this situation it does work, i do same it , i give a main map and a shape file map with one shape
thanks

Options: ReplyQuote


Sorry, only registered users may post in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: