Sunday, September 24, 2017

Resize image dynamically when frame is maximized in wxPython

Hello,

I will work you through on how you will "Resize a wxStaticBitmap image dynamically when frame is maximized in wxPython

Here I have two StaticBitmap images placed side-by-side in box sizers. So, we want the size of the images to scale appropriately with the frame whenever it is been maximized.

The code....

import wx

class MyFrame2 ( wx.Frame ):

    def __init__( self, parent ):
        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )

        self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )

        bSizer11 = wx.BoxSizer( wx.HORIZONTAL )

        self.m_bitmap3 = wx.StaticBitmap( self, wx.ID_ANY, wx.Bitmap( u"img/im1.jpg", wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer11.Add( self.m_bitmap3, 1, wx.ALL|wx.EXPAND, 5 )

        self.m_bitmap4 = wx.StaticBitmap( self, wx.ID_ANY, wx.Bitmap( u"img/im2.jpg", wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer11.Add( self.m_bitmap4, 1, wx.ALL|wx.EXPAND, 5 )


        self.SetSizer( bSizer11 )
        self.Layout()

        self.Centre( wx.BOTH )

    def __del__( self ):
        pass

app = wx.App(0)
MyFrame2(None).Show()
app.MainLoop()

When you first launch the GUI it is like this....



Thursday, September 14, 2017

The Geo in PyCon Nigeria 2017

Hello,

I am privileged to be among the speakers at this year's python conference and the title of my talk is "Using Python for GIS and Remote Sensing Operations".

As I Geo aware individual, I was impressed with the organizers especially the guy behind the conference Venue page.



He did not only added geospatial technology on the page, but he also encouraged users to make use of the tool to make there live easier while locating the conference venue.

The web page is based on python Django web framework (Pinax/Symposion) and on these bases of python & GIS relationships, I decided to write this blog post.


What I did on the Venue Page

On the page there is a "Get Direction" tool, so i used it to get the direction from Abuja where I am coming from.



There and then I have a quick idea of where am going to and how long it will take me to reach there by road or air as seen above.

I also get the direction of my hotel (Presken Hotel) location to the venue and I observed there are two location of the hotel having similar name. However, based on the address provided I realized the correct on is with the name "Presken Hotel (Awolowo way)" and it is about 2km (5min drive) from the venue.



Thank God for Google map, everyone can at least do or interact with GIS without installing any heavy software.



You can find the presentation here: https://github.com/forum2k9/pycon-ng-2017

Thursday, August 31, 2017

Next Step after Learning the Basics of Python Programming

Hello there,

Today I want to share with you things you could do after completing the fundamentals in Python. There is always this dilemma on what NEXT after learning and completing the basic fundamentals of Python Programming.

I will attempt to solve this using my experience after being in similar situation few years ago.

Shortest Solution


The shortest answer will be that: its depend on what you want to use python for, learn related libraries in that niche. For example, if your in the Geospatial/GIS industry then go ahead and search PyPI for related libraries and learn them.


Long Solution

Now its time to program something useful to you in Python and put that theoretical knowledge to accomplishing something practical!

Pick any topic that interests you and learn the libraries related to it. There are many tutorials and documentation out for just about any library you wish to learn.

As you go through tutorial or documentation with code in it, type in all of the code and make it work. That's how I do it. That's how every programmer does it.


Find a project that interests you and try to solve it using Python. It could be in any of the following fields:-

~ Web and Internet Development
~ Scientific and Numeric
~ Education
~ Desktop GUIs
~ Software Development
~ Business Applications

Python Project Ideas

Here you will find list of practical projects to try out. 


Tuesday, August 15, 2017

Reading JSON file into Pandas DataFrame

I wanted to read in a JSON object on a python pandas dataframe for further processing. So, I tried the default pandas read JSON method: read_json('file.json'), but I got just the JSON strings returned in the dataframes's row as seen below. That isn't what I was expecting....



Fortunately for me, pandas has a solution for this in its json_normalize class that “Normalize” semi-structured JSON data into a flat table.


So, I read the JSON file and applied the "json_normalize()" class and boom my semi-structured JSON data was converted into a flat table as seen above.

That was it!

Sunday, August 6, 2017

Convert Projected coordinates (Northings/Eastings) to Geographical (Latitude/Longitude) using Python

Generally, there are two types of coordinate systems used to represent Geospatial data namely:-
1) Geographical Coordinate Systems - Polar coordinates assumes the earth is spheroid/geoid/ellipsoid/curve (Latitude/Longitude). Example: World Geodetic System (WGS) 1984. Geographic coordinate systems are based on a spheroid and utilize angular units (degrees).

2) Projected Coordinate Systems - Rectangular coordinates assumes the earth is flat (Northings/Eastings).Example: Universal Transverse Mercator (UTM) Zone 33. Projected coordinate systems are based on a plane (the spheroid projected onto a 2D surface) and utilize linear units (feet and meters)


Thursday, August 3, 2017

Download Nigeria Geo dataset for States, LGA and Ward levels

Hello,
Are you looking for a complete and comprehensive Geo dataset of Nigeria? Are you looking for complete map of Nigeria at States, LGA and Ward levels?

If yes, then you have come to the right website. Here you can download complete map of Nigeria at States, LGA and Ward levels in different file formats including image files, PDF, shapefile, CSV, GeJSON etc.

Check out the samples below and download. If you have special request, feel free to contact me and I will convert and provide it for you asap.

Download Maps











Thanks for following...
Website: www.UmarYusuf.com
Tel: +2348039508010

Tuesday, August 1, 2017

Web Mapping - case study of Ahmadu Bello University (ABU) Zaria Main Campus (Samaru, Sabo LGA Kaduna State)

Hello there,

In today's post, I will share how to produce a Campus Web Map using free and open source tools.

I will use ABU Zaria as an example. Let's get started....

You need the vector (shapefile) map of the campus. If you don't have one, you can easily obtain a copy from the ABU GIS unit or you can digitize your copy from available google earth satellite image.

You can use any GIS software for this... here I use a free software called QGIS.


There are several free and open source methods of deploying the shapefile map to the web. Some notable method am going to discuss in few moment include:-
1) Google Map Engine
2) QGIS2Web plugin
3) Open Street Map
4) Python Folium Library

Choose any of the methods above to create your web map (there are many guide and tutorials on the internet or contact me for help).

Happy mapping.

Thursday, July 6, 2017

Setting up virtual environment (virtualenv) for python app development

When working on fairly large app in python, it is a good practice to create/setup an isolated python environment (called virtual environment - virtualenv) for development.

There are many long term reason for setting up a python's virtual environment (virtualenv) for any project you are working on. The notable once include:
1) When you have to experiment with something new.
2) When you want to use two different versions of package and compare them.
3) Virtualenv really shines when you have a number of projects, and don't want them to all share the same Python installation. For example, you could have two project with conflicting requirements.
4) Virtualenv will let you define isolated Python runtime environments without harming the root or system python installation. This comes in handy when deploying several python applications and you want to isolate the different environments. Typically this is needed when runtime dependencies differ between frameworks or libraries in different applications.

Creating a virtual environment

Step 1: Create a folder where you want to have the python virtual environment
Step 2: Open CMD or terminal window in that folder
Step 3: Enter "virtualenv name_of_folder" on the cmd/terminal

At this point, you did have a virtual environment created.


Using a virtual environment

Step 1: Open CMD or terminal window in that folder
Step 2: Enter "folder_name\Scripts\activate"
Step 3: To deactivate, simply enter "deactivate"
Step 4: To install packages enter "pip install package_name"
Step 5: To view the install packages enter "pip freeze"
Step 6: To save the install packages to file, enter "pip freeze > file_name.txt"



That is it!

Wednesday, July 5, 2017

QGIS - Restore Missing Vector menu such as: Geometry Tools

Hello,

There is a bug in the 2.16.0 Nodebo version of QGIS. This bug hides some vector processing tools (GDAL tools) found under the "Vector" menu. As already reported here... on the QGIS issues tracking page. This is caused as a result of installing "processing tools" as an external plugin.



Here is how to fix it

To fix this, go to "Plugins" menu and search for "Processing" plugin and enable it.



That is it!
Happy mapping...:)

Thursday, June 22, 2017

How to make Custom Google Map of Nigeria displaying the state capitals

In this post, I will guide you to make a customized Google map displaying the capitals of all the states in Nigeria with additional information attached to each state capital.

I will also show you how to embed it to any html web page.

Let's get started...


Requirements
1) A Google account
2) CSV file containing the states information including longitude and latitude of the state capitals