MapWindow Developer Team : MapWindow Discussion Forum
Still working on my tutorial ;) I'm at the point ArcGIS is saving its layers as a layer file (*.lyr). This way ArcGis can easily open the same shapefile multiple times and every layer with its own coloring. For example. I have a county polygon shapefile with att
[How to]Save a layer and reopen it
Posted by:
pmeems ()
Date: May 11, 2009 07:39AM
Still working on my tutorial ;)
I'm at the point ArcGIS is saving its layers as a layer file (*.lyr).
This way ArcGis can easily open the same shapefile multiple times and every layer with its own coloring.
For example.
I have a county polygon shapefile with attributes like number of citizens, average income, unemployment %, etc.
I want to create a theme layer with a gradient color scheme based on citizens (5 breaks), but I also want a layer based on the same shapefile with a gradient color scheme based on unemployment (6 breaks).
How can I do this?
Thanks,
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
I'm at the point ArcGIS is saving its layers as a layer file (*.lyr).
This way ArcGis can easily open the same shapefile multiple times and every layer with its own coloring.
For example.
I have a county polygon shapefile with attributes like number of citizens, average income, unemployment %, etc.
I want to create a theme layer with a gradient color scheme based on citizens (5 breaks), but I also want a layer based on the same shapefile with a gradient color scheme based on unemployment (6 breaks).
How can I do this?
Thanks,
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
Re: [How to]Save a layer and reopen it
Posted by:
geofran80 ()
Date: May 12, 2009 12:54AM
Hi Paul, if you use LINQ to XML you can serialize more efficient as XML serialization into the last versions of Visual Studio and NET Framework. If you are using VB.NET you can embeb the XML code into the VB.NET Code, and using XML Scheme templates you can recognize the nodes used into the XML file.
Using this you can use simmilar technique as I used to the Bookmarks article as I sent to you to serialize the Layer as XML using the nodes and subnodes to save and restore the Layer properties as follow:
<Layer Handle="0" Position="1">
<LocationPath>C:\Layer.Shp</LocationPath>
<LayerType>Shapefile</LayerType>
<LayerSymbol>
<SymbologyType>Unique Values</SymbologyType>
<SymbolScheme Layer="0" Field="1">
<SymbolSchemeBreak BreakNumber="0">
<BreakStartColor>ValueColor</BreakEndColor>
<BreakStartValue>Value</BreakStartValue>
<BreaKStartColor>ValueColor</BreakEndColor>
<BreakStopValue>Value</BreakStopValue>
</SymbolSchemeBreak>
<SymbolSchemeBreak BreakNumber="1">
<BreakStartColor>ValueColor</BreakEndColor>
<BreakStartValue>Value</BreakStartValue>
<BreaKStartColor>ValueColor</BreakEndColor>
<BreakStopValue>Value</BreakStopValue>
</SymbolSchemeBreak>
.... 'Another Breaks
</SymbolScheme>
... 'Another Properties
</LayerSymbol>
</Layer>
Where ValueColor is one UINT32 value to the color.
Using the SymbologyType based into one Enumeration you can select the type of symbology used to colours and symbolize the shapefile or another layer.
To populate some values into the XML if you are using LINQ to XML and VB.NET you can use <%= ClassInstance.ValueMemberProperty %> to populate it.
You can add more data to the properties of the Layer to restore in more efficient conditions as you need.
To restore it you only need to load the XML and assign the XML nodes values into the properties and methos as you need. Using LINQ to XML is more efficient as using another serialization mode.
The xml file you can save into another extension as example (*.mwLyr) as MapWindow Layer.
Hope it serves to you.
Francisco J.
Edited 2 time(s). Last edit at 05/12/2009 12:57AM by geofran80.
Using this you can use simmilar technique as I used to the Bookmarks article as I sent to you to serialize the Layer as XML using the nodes and subnodes to save and restore the Layer properties as follow:
<Layer Handle="0" Position="1">
<LocationPath>C:\Layer.Shp</LocationPath>
<LayerType>Shapefile</LayerType>
<LayerSymbol>
<SymbologyType>Unique Values</SymbologyType>
<SymbolScheme Layer="0" Field="1">
<SymbolSchemeBreak BreakNumber="0">
<BreakStartColor>ValueColor</BreakEndColor>
<BreakStartValue>Value</BreakStartValue>
<BreaKStartColor>ValueColor</BreakEndColor>
<BreakStopValue>Value</BreakStopValue>
</SymbolSchemeBreak>
<SymbolSchemeBreak BreakNumber="1">
<BreakStartColor>ValueColor</BreakEndColor>
<BreakStartValue>Value</BreakStartValue>
<BreaKStartColor>ValueColor</BreakEndColor>
<BreakStopValue>Value</BreakStopValue>
</SymbolSchemeBreak>
.... 'Another Breaks
</SymbolScheme>
... 'Another Properties
</LayerSymbol>
</Layer>
Where ValueColor is one UINT32 value to the color.
Using the SymbologyType based into one Enumeration you can select the type of symbology used to colours and symbolize the shapefile or another layer.
To populate some values into the XML if you are using LINQ to XML and VB.NET you can use <%= ClassInstance.ValueMemberProperty %> to populate it.
You can add more data to the properties of the Layer to restore in more efficient conditions as you need.
To restore it you only need to load the XML and assign the XML nodes values into the properties and methos as you need. Using LINQ to XML is more efficient as using another serialization mode.
The xml file you can save into another extension as example (*.mwLyr) as MapWindow Layer.
Hope it serves to you.
Francisco J.
Edited 2 time(s). Last edit at 05/12/2009 12:57AM by geofran80.
Re: [How to]Save a layer and reopen it
Posted by:
geofran80 ()
Date: May 12, 2009 01:00AM
Sorry i forgot it,
If you take the ShapefileColorScheme and implements IComparable or IComparer you could evaluate using one Array or List(of ColorSchemeBreaks) to see if the list is possible to populate into the ShapefileColorScheme to use it into another layer if the values are simmilar or it is into the range values.
Hope it serves to you.
Francisco J.
If you take the ShapefileColorScheme and implements IComparable or IComparer you could evaluate using one Array or List(of ColorSchemeBreaks) to see if the list is possible to populate into the ShapefileColorScheme to use it into another layer if the values are simmilar or it is into the range values.
Hope it serves to you.
Francisco J.
Re: [How to]Save a layer and reopen it
Posted by:
pmeems ()
Date: May 12, 2009 01:33AM
Thanks Francisco,
I was also thinking of saving the piece of the project file to a separate file.
I did not yet thought of using LINQ. I'm not very familiar with that, but I will look in to it.
If you've got the time I'd be more than happy if you could add it to MW.
Let say to the legend control? In the context menu a new option 'Save as/to layer'?
Thinking of that I don't know if it should be added to the core. Using LINQ requires .NET3.5 and the core is .NET2.0. Perhaps a separate plug-in? Or don't use LINQ?
Thanks,
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
I was also thinking of saving the piece of the project file to a separate file.
I did not yet thought of using LINQ. I'm not very familiar with that, but I will look in to it.
If you've got the time I'd be more than happy if you could add it to MW.
Let say to the legend control? In the context menu a new option 'Save as/to layer'?
Thinking of that I don't know if it should be added to the core. Using LINQ requires .NET3.5 and the core is .NET2.0. Perhaps a separate plug-in? Or don't use LINQ?
Thanks,
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
Re: [How to]Save a layer and reopen it
Posted by:
geofran80 ()
Date: May 12, 2009 02:06AM
Dear Paul,
I think that if the project is migrated into VS 2008 and .NET Framework 3.5 I could make one extension method to save and restore the Legend Item based into the main properties of the Layer as you have seen in my last post. Later you and another users could add more properties in the module used to create the extension method to get more efficient save/restore layer items.
The extension method could affect to the Legend or the Map.
When the project will be into the .NET 3.5 and VStudio 2008 i'll make it.
I haven't any problem to migrate, I'm using all my projects into VStudio 2008 and trying the Beta version of VStudio 2010.
Thanks.
Francisco J.
I think that if the project is migrated into VS 2008 and .NET Framework 3.5 I could make one extension method to save and restore the Legend Item based into the main properties of the Layer as you have seen in my last post. Later you and another users could add more properties in the module used to create the extension method to get more efficient save/restore layer items.
The extension method could affect to the Legend or the Map.
When the project will be into the .NET 3.5 and VStudio 2008 i'll make it.
I haven't any problem to migrate, I'm using all my projects into VStudio 2008 and trying the Beta version of VStudio 2010.
Thanks.
Francisco J.
Re: [How to]Save a layer and reopen it
Posted by:
pmeems ()
Date: May 13, 2009 03:55AM
Thanks Francisco,
I've just started a new discussion about .NET 3.5: {Discussion} Move MapWindow to .NET 3.5
We need to wait for those results and then I will submit an enhancement request in Mantis with samples, documentations, etc. and put it on your name.
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
I've just started a new discussion about .NET 3.5: {Discussion} Move MapWindow to .NET 3.5
We need to wait for those results and then I will submit an enhancement request in Mantis with samples, documentations, etc. and put it on your name.
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
Re: [How to]Save a layer and reopen it
Posted by:
geofran80 ()
Date: May 13, 2009 04:54AM
Thanks Paul, I read it.
I will be alert to this thread and documentation, mantis, and so.
Francisco J.
I will be alert to this thread and documentation, mantis, and so.
Francisco J.
Sorry, only registered users may post in this forum.


